<?php
/**
 * 兼容第三方插件补丁文件
 * @来自第三方接口文件
 */
		defined('BY_JYA') or exit('error');
		list($mobilea,$mobileb)=$arguments;
		$setting=$this->get_setting();
		if(!$setting['appkey'] || !$setting['secret'] || !$setting['poolkey']){
			return error('参数错误');
		}
		$appkey=$setting['appkey'];
		$secret=$setting['secret'];
		$poolkey=$setting['poolkey'];
		date_default_timezone_set("Etc/GMT-8");
		$Expiration=date('Y-m-d H:i:s',TIMESTAMP+1800);
		$params=array(
		"PoolKey"=>$poolkey,
		"PhoneNoA"=>$mobilea,
		"PhoneNoB"=>$mobileb,		
		"Expiration"=>$Expiration
		);
		$loga=pdo_get('jy_alisms_bd',array('mobile'=>$mobilea));
		$logb=pdo_get('jy_alisms_bd',array('mobile'=>$mobileb));
		//未到失效时间 手动解绑
		if(strtotime($loga['time'])> TIMESTAMP){
			$params1=array(
			"PoolKey"=>$poolkey,
			"ProductType"=>'AXB_170',
			"SecretNo"=>$loga['ysmobile'],		
			"SubsId"=>$loga['bdno']
			);
			$return=Aliyun\DySDKLite\Pls\Demo\unbindSubscription($appkey,$secret,$params1);
			$return=(array)$return;
			
			if($return['Code']=='OK'){
					$r=pdo_get('jy_alisms_bd',array('bdno'=>$loga['bdno']));
					//print_r($r);exit();
					pdo_delete('jy_alisms_bd',array('bdno'=>$loga['bdno']));
					$ysmobile=$logb['ysmobile'];
				}else{
					
				return error('解绑失败');
			}
		}else{
			pdo_delete('jy_alisms_bd',array('bdno'=>$loga['bdno']));
		}
		if(strtotime($logb['time'])> TIMESTAMP){
			$params1=array(
			"PoolKey"=>$poolkey,
			"ProductType"=>'AXB_170',
			"SecretNo"=>$logb['ysmobile'],		
			"SubsId"=>$logb['bdno']
			);
			$return=(array)$return;
			$return=Aliyun\DySDKLite\Pls\Demo\unbindSubscription($appkey,$secret,$params1);	
			$return=(array)$return;
			if($return['Code']=='OK'){	
				pdo_delete('jy_alisms_bd',array('bdno'=>$loga['bdno']));
				$ysmobile=$logb['ysmobile'];
			}else{
			return error('解绑失败');
			}
		}else{
			pdo_delete('jy_alisms_bd',array('bdno'=>$loga['bdno']));
		}
		if($ysmobile){
			$mobile=$setting['mobile'];
			$mobile=explode(',',$mobile);
			
			foreach ($mobile as $key=>$value)
			 {
				if ($value == $ysmobile)
				unset($mobile[$key]); 
			 }
			$params['PhoneNoX']=$mobile['0'];
		}
		$return=Aliyun\DySDKLite\Pls\Demo\bindAxb($appkey,$secret,$params);
		$return=(array)$return;	
		$pluginname=$this->from_plugin;
		if(!$pluginname){
			$pluginname='core';
		}
		$bind=(array)$return['SecretBindDTO'];
		$ysmobile=$bind['SecretNo'];
		$data=array(
			'uniacid'=>$_SESSION['uniacid'],
			'plugin'=>$pluginname,
			'remake'=>$return['Code'].'：'.$return['Message'],
			'createtime'=>time(),
			'mobile'=>$ysmobile,
		);
		$this->insert('dayu_log',$data);
		if($return['Code']=='OK'){
			
			$bdno=$bind['SubsId'];
			$data=array(
				'uniacid'=>$_SESSION['uniacid'],
				'ysmobile'=>$ysmobile,
				'bdno'=>$bdno,
				'time'=>$Expiration,
			);
			$data['mobile']=$mobilea;
			pdo_insert('jy_alisms_bd',$data);
			$data['mobile']=$mobileb;
			pdo_insert('jy_alisms_bd',$data);
			//print_r($return);exit();
			$status=1;
			//$re=array('status'=>'1','ysmobile'=>$ysmobile);
			return $ysmobile;
		}else{
			
			return error($return['Code']);
		}
	
